package com.shushan.pages.bean;

import com.android.net.bean.NetBaseBean;
import com.shushan.base.Constants;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * @ClassName: SyncExerciseDetailBean
 * @Desciption: //同步练习详情bean
 * @author: zhangshihao
 * @date: 2018-04-18
 */
public class SyncExerciseDetailBean extends NetBaseBean {

    public int progress_lock;//0:学生不可调节进度1:学生可以调节
    public int znlx;
    public int paper_id;

    public SubjectSyncExerciseBean chineseSyncExerciseBean;
    public SubjectSyncExerciseBean mathSyncExerciseBean;
    public SubjectSyncExerciseBean englishSyncExerciseBean;

    public int score;
    public int time;

    @Override
    public void initByJson(JSONObject jsonObject) throws JSONException {
        if (jsonObject != null) {
            znlx = jsonObject.optInt("znlx", 0);
            paper_id = jsonObject.optInt("paper_id", 0);
            progress_lock = jsonObject.optInt("progress_lock", 0);
            JSONObject subject = jsonObject.optJSONObject("subject");
            JSONObject chinese = subject.optJSONObject(Constants.SUBJECT_CHINESE_ID+"");
            if (chinese != null && chinese.length() > 0) {
                chineseSyncExerciseBean = new SubjectSyncExerciseBean();
                chineseSyncExerciseBean.initByJson(chinese);
            }
            JSONObject math = subject.optJSONObject(Constants.SUBJECT_MACH_ID+"");
            if (math != null && math.length() > 0) {
                mathSyncExerciseBean = new SubjectSyncExerciseBean();
                mathSyncExerciseBean.initByJson(math);
            }
            JSONObject english = subject.optJSONObject(Constants.SUBJECT_ENGLISH_ID+"");
            if (english != null && english.length() > 0) {
                englishSyncExerciseBean = new SubjectSyncExerciseBean();
                englishSyncExerciseBean.initByJson(english);
            }

            JSONObject rewardObj = jsonObject.optJSONObject("reward");
            score = rewardObj.optInt("score",0);
            time = rewardObj.optInt("time",0);
        }
    }
}
